// ObjectRegister.h: interface for the ObjectRegister class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_OBJECTREGISTER_H__2E4F5B78_DEFA_416A_AAEB_55CCB89ED4E1__INCLUDED_)
#define AFX_OBJECTREGISTER_H__2E4F5B78_DEFA_416A_AAEB_55CCB89ED4E1__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "MultiRecordsDatabaseElement.h"

namespace PDMS
{
	namespace PDMSDBIF
	{
		class ObjectRegisterRecord
		{
		public:
			void SetID( long lID ) {
				m_bIsIDModified = TRUE;
				m_lID = lID;
			}

			long GetID() const {
				return m_lID;
			}

			void SetClassName( const StdString& strName ) {
				m_bIsClassNameModified = TRUE;
				m_strClassName = strName;
			}

			void SetObjectName( const StdString& strName ) {
				m_bIsObjectNameModified = TRUE;
				m_strObjectName = strName;
			}
			
			const StdString& GetObjectName() const {
				return m_strObjectName;
			}

			const StdString& GetClassName() const {
				return m_strClassName;
			}
			
			BOOL IsIDModified() const {
				return m_bIsIDModified;
			}

			BOOL IsClassNameModified() const {
				return m_bIsClassNameModified;
			}

			BOOL IsObjectNameModified() const {
				return m_bIsObjectNameModified;
			}
		public:
			ObjectRegisterRecord() {
				m_bIsClassNameModified = FALSE;
				m_bIsIDModified = FALSE;
				m_bIsObjectNameModified = FALSE;
			}
		private:
			long m_lID;
			StdString m_strClassName;
			StdString m_strObjectName;
			BOOL m_bIsIDModified;
			BOOL m_bIsClassNameModified;
			BOOL m_bIsObjectNameModified;
		};

		typedef DatabaseTableTemplate< ObjectRegisterRecord > ObjectRegisterBase;

		class DllExport ObjectRegister : 
						public ObjectRegisterBase 
		{
			DECLARE_REGISTER_MAP( ObjectRegister );
		public:
			ObjectRegister();
			virtual ~ObjectRegister();
			
		public:
			void SetID( long lID ) {
				ASSERT( m_pCurRecord );
				m_pCurRecord->SetID( lID );
			}

			void SetClassName( const StdString& strName ) {
				ASSERT( m_pCurRecord );
				m_pCurRecord->SetClassName( strName );
			}

			void SetObjectName( const StdString& strName ) {
				ASSERT( m_pCurRecord );
				m_pCurRecord->SetObjectName( strName );
			}

			long GetID();
			StdString GetClassName();
			StdString GetObjectName();
		protected:
			virtual StdString GetOpenSQL( const StdString& strCondition );
			virtual StdString GetTableName();
			virtual void SetData( RecordPtr_ ptr );

		private:
		};

	}
}
#endif // !defined(AFX_OBJECTREGISTER_H__2E4F5B78_DEFA_416A_AAEB_55CCB89ED4E1__INCLUDED_)
